'''
Author: error: git config user.name && git config user.email & please set dead value or install git
Date: 2022-10-26 13:17:44
LastEditors: error: git config user.name && git config user.email & please set dead value or install git
LastEditTime: 2022-10-29 14:10:52
FilePath: \新建文件夹\随机猜数.py
Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AE
'''
#coding:utf-8
import time
import random
from tkinter import *
masterWindow = Tk()
masterWindow.title('猜数游戏')
masterWindow.geometry('400x300')
Answer=random.randint(1,200)
timesCurrent=0
def guessProcess():

  global timesCurrent;
  result = int (guessValue.get())
  if result > Answer:
     outputLabel['text']='大了,继续努力...'
  elif result < Answer:
     outputLabel['text']='小了,继续努力...'
     
  else:
     outputLabel['text']='恭喜你,猜对了!'
  timesCurrent = timesCurrent + 1
  outputLabel_1['text'] = str ( timesCurrent )

Label1 = Label (masterWindow,text='猜猜看',width=6,font= (",'18',"))
Label1.grid (row=1,column=0,rowspan=1,columnspan=1,pady=20,sticky="e")
guessValue = StringVar()
guessInput = Entry ( masterWindow,textvariable = guessValue,font= (",'18',"))
guessValue.set("")
guessInput.grid( row=1,column=6,rowspan=1,pady=20,columnspan=1)
Label2 = Label ( masterWindow,text='你猜的结果',width=10,font= (",'18',"))
Label2.grid ( row=3,column=0,rowspan=10,columnspan=1,pady=20,sticky="e")
outputLabel= Label ( masterWindow,text='这是猜测的结果',width=20,font=(",'18'"),bg="white")
outputLabel.grid(row=3, column=6,rowspan=10,columnspan=1,pady=20,sticky="w")
Label4 = Label ( masterWindow,text='试猜次数',width=10,font= (",'18',"))
Label4.grid ( row=14,column=0,rowspan=10,columnspan=1,pady=20,sticky="e")
outputLabel_1=Label ( masterWindow,text='',width=20,font=(",'18',"),bg="white")
outputLabel_1.grid ( row=14,column=6,rowspan=10,columnspan=1,pady=20,sticky="w")
okButton = Button ( masterWindow,text='确定',command = (lambda x=ALL:guessProcess()),width=10,height=1,font=(",'20','bold'"))
okButton.grid ( row=24,column=2,rowspan=5,columnspan=5,pady=20)

masterWindow.mainloop()

